package database.demo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseWrapperPassengers extends SQLiteOpenHelper {

	public static final String PASSENGERS = "Passengers";
	public static final String PASSENGER_ID = "_id";
	public static final String PASSENGER_LASTNAME = "_lastname";
	public static final String PASSENGER_FIRSTNAME = "_firstname";
	public static final String PASSENGER_PHONE = "_phone";
	public static final String PASSENGER_EMAIL = "_email";
	public static final String PASSENGER_NOTE = "_note";
	public static final String PASSENGER_PRESENT = "_present";
	public static final String PASSENGER_UPDATE = "_update";
	
	private static final String DATABASE_NAME = "Passangers.db";
	private static final int DATABASE_VERSION = 1;

	// creation SQLite statement
	private static final String DATABASE_CREATE = "create table " + PASSENGERS
			+ "(" + PASSENGER_ID + " text primary key, "
			+ PASSENGER_LASTNAME + " text, "
			+ PASSENGER_FIRSTNAME + " text, "
			+ PASSENGER_PHONE + " text, "
			+ PASSENGER_EMAIL + " text, "
			+ PASSENGER_NOTE + " text, "
			+ PASSENGER_PRESENT + " boolean, "
			+ PASSENGER_UPDATE + " text"
			+ ");";

	public DataBaseWrapperPassengers(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		//db.execSQL("DROP TABLE IF EXISTS " + PASSANGERS);
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// you should do some logging in here
		// ..
		db.execSQL("DROP TABLE IF EXISTS " + PASSENGERS);
		onCreate(db);
	}
	
	
}